package o;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.content.DialogInterface.OnShowListener;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import BaseDialog.a;
import o.exp.d;
import o.exp.j;

public class fan extends BaseAlertDialog implements OnShowListener {
    private String ʻ;
    private int ʼ;
    private Intent ʽ;
    private ScrollView ˋ;
    private OnDismissListener ˋॱ;
    private LinearLayout ˎ;
    protected Activity ॱ;
    private String ॱॱ;
    private String ᐝ;

    fan(Activity activity, Intent intent) {
        super(activity, activity.getResources().getString(exp$f.ॱॱ), null);
        this.ʽ = intent;
        this.ॱ = activity;
    }

    private boolean ˊ() {
        this.ॱॱ = this.ʽ.getStringExtra("appId");
        this.ᐝ = this.ʽ.getStringExtra("packageName");
        this.ʻ = this.ʽ.getStringExtra("newFeatures");
        this.ʼ = this.ʽ.getIntExtra("isForceUpdate", 0);
        if (dof.ˋ(this.ʻ) || dof.ˋ(this.ॱॱ) || dof.ˋ(this.ᐝ)) {
            return false;
        }
        return true;
    }

    private void ॱॱ() {
        LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(this.ॱ).inflate(j.ˉ, null);
        this.ˋ = (ScrollView) linearLayout.findViewById(d.ॱˈ);
        this.ˎ = (LinearLayout) linearLayout.findViewById(d.ߵ);
        ((TextView) linearLayout.findViewById(d.ߺ)).setText(this.ʻ);
        ˏ(a.ॱ, 8);
        if (this.ʼ == 1) {
            ˏ(a.ˎ, 8);
        }
        ˊ(linearLayout);
        ˊ(this);
        ˎ(new cks(this) {
            final /* synthetic */ fan ॱ;

            {
                this.ॱ = r1;
            }

            public void enableNetworking() {
                Intent intent = new Intent("com.huawei.appmarket.intent.action.AppDetail");
                intent.putExtra("APP_PACKAGENAME", this.ॱ.ᐝ);
                intent.putExtra("thirdId", "hwgamebuoy");
                intent.setPackage(ContentManager.getInstant().getContext().getPackageName());
                this.ॱ.ॱ.startActivity(intent);
                ezy.ˏ().ˋ(this.ॱ.ॱॱ);
            }

            public void upgrade() {
                ezy.ˏ().ˎ(this.ॱ.ॱॱ);
                ezy.ˏ().ˋ(this.ॱ.ॱॱ);
                if (Logger.ˎ()) {
                    Logger.ˏ("GameServiceUpdateDialog", "User cancel update");
                }
            }

            public void ˋ() {
            }
        });
    }

    private int ˊ(Context context) {
        if (context.getResources().getConfiguration().orientation == 2) {
            return (int) (0.9d * ((double) epv.ˎ(context)));
        }
        return (int) (0.8d * ((double) epv.ॱ(context)));
    }

    public void ˎ(OnDismissListener onDismissListener) {
        this.ˋॱ = onDismissListener;
    }

    private void ᐝ() {
        Logger.ˏ("GameServiceUpdateDialog", "start to check height");
        if (this.ˎ != null) {
            int height = this.ˎ.getHeight();
            int height2 = this.ˋ.getHeight();
            if (height - height2 > 0) {
                Logger.ˏ("GameServiceUpdateDialog", "scrollViewContentHeight - scrollViewHeight > 0");
                int ˊ = ˊ(this.ˏ);
                Dialog ˋ = ˋ();
                int ˏ = ˏ(ˋ);
                if (Logger.ˎ()) {
                    Logger.ˏ("GameServiceUpdateDialog", "distance > 0, dialogMaxHeight: " + ˊ + "; currentDialogHeight:" + ˏ);
                }
                if (ˏ > ˊ) {
                    Logger.ˏ("GameServiceUpdateDialog", "currentDialogHeight > maxDailogHeight");
                    return;
                }
                ˊ -= ˏ;
                height -= height2;
                if (Logger.ˎ()) {
                    Logger.ˏ("GameServiceUpdateDialog", "resize realChangeHeight: " + height + " ;changeMaxHeight:" + ˊ);
                }
                LayoutParams layoutParams = this.ˋ.getLayoutParams();
                if (Logger.ˎ()) {
                    Logger.ˏ("GameServiceUpdateDialog", "scrollViewHeight: " + height2);
                }
                if (height > ˊ) {
                    if (Logger.ˎ()) {
                        Logger.ˏ("GameServiceUpdateDialog", "resize realChangeHeight > changeMaxHeight");
                    }
                    layoutParams.height = height2 + ˊ;
                    height = ˏ + ˊ;
                    if (Logger.ˎ()) {
                        Logger.ˏ("GameServiceUpdateDialog", "scrollView change height to :" + layoutParams.height + "  dialog change height to: " + height);
                    }
                } else {
                    if (Logger.ˎ()) {
                        Logger.ˏ("GameServiceUpdateDialog", "resize realChangeHeight <= changeMaxHeight");
                    }
                    layoutParams.height = height2 + height;
                    height += ˏ;
                }
                this.ˋ.setLayoutParams(layoutParams);
                ˎ(ˋ, height);
                this.ˋ.smoothScrollBy(0, 10);
            }
        }
    }

    public void ॱ() {
        if (!ˊ()) {
            ˏ();
        }
        ॱॱ();
        super.ॱ();
        if (ˋ() != null) {
            ˋ().setOnDismissListener(this.ˋॱ);
        }
        ˎ(false);
        ॱ(false);
        ॱ(a.ˋ, exp$f.ͺ);
        ॱ(a.ˎ, exp$f.ˊॱ);
    }

    public void onShow(DialogInterface dialogInterface) {
        ᐝ();
    }

    private int ˏ(Dialog dialog) {
        if (dialog != null && dialog.getWindow() != null) {
            return dialog.getWindow().getDecorView().getHeight();
        }
        Logger.e("GameServiceUpdateDialog", "dialog == null || dialog.getWindow() == null || dialog.getWindow().getDecorView() == null");
        return 0;
    }

    private void ˎ(Dialog dialog, int i) {
        if (dialog != null) {
            Window window = dialog.getWindow();
            if (window != null) {
                WindowManager.LayoutParams attributes = window.getAttributes();
                attributes.height = i;
                if (Logger.ˎ()) {
                    Logger.ˏ("GameServiceUpdateDialog", "reset Dialog height" + i);
                }
                window.setAttributes(attributes);
            }
        }
    }
}
